#include<bits/stdc++.h>
//#define int long long
#define endl '\n'
using namespace std;
const int inf=0x3f3f3f3f3f3f3f3f;
const int N=2e5+10,M=2e5+10;
mt19937 rnd(time(0));
const int B=500;
int n,f[B+10][N],mod;
int cnt[B+10];
void init()
{
	n=2e5;
	f[0][0]=1;
	for ( int i = 1 ; i <= B ; i++ )
	{
//		cerr << i << endl;
		for ( int j = 0 ; j <= n ; j++ )
		{
//			cerr << i << " " << j << endl;
			cnt[j%i]+=f[i-1][j];
			if(cnt[j%i]>=mod)cnt[j%i]-=mod;
			f[i][j]=cnt[j%i];
		}
		memset(cnt,0,sizeof(cnt));
	}
}
void solve()
{
	cin >> n;
	int ans=0;
	for ( int i = 1 ; i*i <= n ; i++ )
	{
		int sy=n-i*i;
		if(sy&1)continue;
		sy/=2;ans=(f[i][sy]+ans)%mod;
	}
	cout << ans%mod << endl;
}
signed main()
{
	ios::sync_with_stdio(false);
	cin.tie(0),cout.tie(0);
	freopen("moon.in","r",stdin);
	freopen("moon.out","w",stdout);
	int T;cin >> T >> mod;init();
	while(T--)solve();
	return 0;
}


